<?php
namespace app\admin\model;


use think\Db;

class AuthModel extends BaseModel
{
    protected $table_name = 'auth';


    public function lists($where = [],$order = 'id asc'){
        if(empty($order)){
            $order = 'id asc';
        }
        return $this->where($where)->order($order)->select()->toArray();
    }
    public function getIsMenuAttr($data){
        return $data == 1 ? '是':'否';
    }

    public function get_nav_tree($nav_id,$tree = []){
        $where = [];
        $where['id'] = $nav_id;
        $auth = Db::table($this->table)->where($where)->order('id desc')->find();
        $tree[] = $auth;
        if($auth['nav_pid'] == 0){
            return $tree;
        }else{
            return $this->get_nav_tree($auth['nav_pid'],$tree);
        }
    }


    /**
     * 获取数据中所有的权限
     * 1:status = 1
     */
    public function get_all_auth(){
       return $this->selectData(['status'=>1]);
    }
}
